﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>engage_major_releaseTo</title>
    <script src="~/lib/axios/dist/axios.js"></script>
    <script src="~/lib/vue/dist/vue.js"></script>
    <script src="~/lib/element-ui/lib/index.js"></script>
    <link href="~/lib/element-ui/lib/theme-chalk/index.css" rel="stylesheet" />
</head>
<body>
    <div id="app">
        <el-container>
            <el-header>
                <el-card class="box-card">
                    <el-col :span="2"> 职位发布变更 </el-col><el-col :span="4" :offset="19"> 当前可变更是职位发布总数：{{total}}例 </el-col>
                </el-card>
            </el-header>
            <el-main>
                <el-card class="box-card">
                    <el-table :data="list" style="width: 100%" border stripe>
                        <el-table-column prop="major_name"
                                         label="职位名称"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="second_kind_name"
                                         label="公司名称"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="human_amount"
                                         label="招聘人数"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="regist_time"
                                         label="发布时间"
                                         align="center"
                                         :formatter="dateFormat">
                        </el-table-column>
                        <el-table-column prop="deadline"
                                         label="截止时间"
                                         align="center"
                                         :formatter="dateFormat">
                        </el-table-column>
                        <el-table-column label="操作" align="center">
                            <template slot-scope="scope">
                                <el-button size="mini" type="primary" @@click="cz(scope.row)">编辑</el-button>
                                <el-button size="mini" type="danger" @@click="delt(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>

                    <el-row>
                        <el-col :span="1">
                            <el-pagination v-on:size-change="handleSizeChange"
                                           v-on:current-change="handleCurrentChange"
                                           :current-page="queryinfo.currentPage"
                                           :page-sizes="[1, 2, 3, 4]"
                                           :page-size="queryinfo.pageSize"
                                           layout="total, sizes, prev, pager, next, jumper"
                                           :total="total">
                            </el-pagination>
                        </el-col>
                    </el-row>
                </el-card>
            </el-main>
        </el-container>
        <el-dialog 
                   :visible.sync="dialogVisibleUpdate"
                   width="80%">
            <el-form ref="form" :model="form" :rules="rules" label-width="80px" :inline="true">
                <el-form-item label="机构选择" prop="value">
                    <div class="block">
                        <el-cascader v-model="form.value"
                                     :options="lis"
                                     ref="cascaderAddr"
                                     style="width: 100% "
                                     @@change="adminSelect"></el-cascader>
                    </div>
                </el-form-item>
                <el-form-item label="招聘类型" prop="engage_type">
                    <el-select v-model="form.engage_type" placeholder="请选择招聘类型" style="width: 100% ">
                        <el-option label="校园招聘" value="校园招聘"></el-option>
                        <el-option label="社会招聘" value="社会招聘"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="职位选择" prop="values">
                    <div class="block">
                        <el-cascader v-model="form.values"
                                     :options="lisd"
                                     ref="cascaderAddr1"
                                     style="width: 100% "
                                     @@change="adminSelect1"></el-cascader>
                    </div>
                </el-form-item>
                <el-form-item label="招聘人数" prop="human_amount">
                    <el-input v-model="form.human_amount" style="width: 130px "></el-input>
                </el-form-item>
                <el-form-item prop="deadline" label="截止日期">
                    <el-date-picker style="width: 140px " type="date" placeholder="选择日期" v-model="form.deadline"></el-date-picker>
                </el-form-item>
                <el-form-item label="变更人" prop="changer">
                    <template>
                        <el-select v-model="form.changer" placeholder="请选择变更人" style="width: 160px ">
                            <el-option v-for="item in listm"
                                       :key="item.u_id"
                                       :label="item.u_true_name"
                                       :value="item.u_true_name">
                            </el-option>
                        </el-select>
                    </template>
                </el-form-item>
                <el-form-item prop="change_time" label="变更时间">
                    <el-date-picker style="width: 200px " :disabled="true" type="datetime" placeholder="选择日期" v-model="form.change_time"></el-date-picker>
                </el-form-item>

                <el-form-item label="职位描述" prop="major_describe">
                    <el-input type="textarea" v-model="form.major_describe" style="width: 850px"></el-input>
                </el-form-item>

                <el-form-item label="招聘要求" prop="engage_required">
                    <el-input type="textarea" v-model="form.engage_required" style="width: 850px "></el-input>
                </el-form-item>
                <el-form-item class="_klpo">
                    <template>
                        <el-button type="primary" @@click="submitForm('form')">修改</el-button>
                    </template>
                    <el-button @@click="dialogVisibleUpdate = false">取 消</el-button>
                </el-form-item>
            </el-form> 
        </el-dialog>

    </div>
    <script type="text/javascript">
        var vm = new Vue({
            el: "#app",
            data: {
                dialogVisibleUpdate: false,                //修改模态框
                list: [],
                queryinfo: {
                    currentPage: 1,                //当前页数
                    pageSize: 3                //显示数
                },
                total: 1,//总人数
                listm: [],//用户表
                lis: [],//机构表
                lisd: [],//职位表
                form: {
                    value: [],
                    values: [],
                    first_kind_id: '',
                    first_kind_name: '',
                    second_kind_id: '',
                    second_kind_name: '',
                    third_kind_id: '',
                    third_kind_name: '',
                    major_kind_id: '',
                    major_kind_name: '',
                    major_id: '',
                    major_name: '',
                    human_amount: '',
                    engage_type: '',
                    deadline: '',
                    register: '',
                    regist_time: '',
                    major_describe: '',
                    engage_required: '',
                    changer: '',
                    change_time: '',
                    mre_id:''
                },
                rules: {
                    value: [
                        { required: true, message: '请选择机构', trigger: 'change' }
                    ],
                    engage_type: [
                        { required: true, message: '请选择招聘类型', trigger: 'change' }
                    ],
                    values: [
                        { required: true, message: '请选择职位', trigger: 'change' }
                    ],
                    human_amount: [
                        { required: true, message: '请填写招聘人数', trigger: 'blur' },
                    ],
                    changer: [
                        { required: true, message: '请选择变更人', trigger: 'change' }
                    ],
                    major_describe: [
                        { required: true, message: '请填写职位描述', trigger: 'blur' }
                    ],
                    engage_required: [
                        { required: true, message: '请填写招聘要求', trigger: 'blur' }
                    ]
                }
            },
            methods: {
                //时间格式优化
                dateFormat(row, column) {
                    // 获取单元格数据
                    let data = row[column.property]
                    if (data == null) {
                        return null
                    }
                    let dt = new Date(data)
                    return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate();
                },
                submitForm(formName) {
                    //表单验证
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.$confirm('此操作将发布招聘信息, 是否发布?', '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                type: 'warning'
                            }).then(() => {
                                this.update();
                            }).catch(() => {
                                this.$message({
                                    type: 'info',
                                    message: '已取消发布'
                                });
                            });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                submitFormt(formName) {
                    //表单验证
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.$confirm('此操作将发布招聘信息删除, 是否删除?', '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                type: 'warning'
                            }).then(() => {
                                this.delt();
                            }).catch(() => {
                                this.$message({
                                    type: 'info',
                                    message: '已取消删除'
                                });
                            });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                //删除
                delt(row) {
                    this.$confirm('此操作将发布招聘信息删除, 是否删除?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        axios.get('/engage_major_releaseTo/Delt', {
                            params: {
                                mre_id: row.mre_id
                            }
                        }).then(res => {
                            console.info(res);
                            if (res.data == 1) {
                                this.$message({
                                    type: 'success',
                                    message: '删除成功!'
                                });
                            }
                            this.fill();
                        })
                            .catch(err => {
                                console.info(err);
                            })
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消删除'
                        });
                    });
                },
                //修改
                update() {
                    axios.get('/engage_major_releaseTo/Update', {
                        params: {
                            first_kind_id: this.form.first_kind_id,
                            first_kind_name: this.form.first_kind_name,
                            second_kind_id: this.form.second_kind_id,
                            second_kind_name: this.form.second_kind_name,
                            third_kind_id: this.form.third_kind_id,
                            third_kind_name: this.form.third_kind_name,
                            major_kind_id: this.form.major_kind_id,
                            major_kind_name: this.form.major_kind_name,
                            major_id: this.form.major_id,
                            major_name: this.form.major_name,
                            human_amount: this.form.human_amount,
                            engage_type: this.form.engage_type,
                            deadline: this.form.deadline,
                            changer: this.form.changer,
                            change_time: this.form.change_time,
                            major_describe: this.form.major_describe,
                            engage_required: this.form.engage_required,
                            mre_id: this.form.mre_id
                        }
                    })
                        .then(res => {
                            console.info(res);
                            if (res.data == 1) {
                                this.$message({
                                    type: 'success',
                                    message: '修改成功!'
                                });
                            }
                            this.fill();
                            this.dialogVisibleUpdate = false;
                        })
                        .catch(err => {
                            console.info(err);
                        })
                },
                //回显
                cz(row) {
                    var rues = [];
                    rues.push(row.first_kind_id);
                    rues.push(row.second_kind_id);
                    rues.push(row.third_kind_id);
                    this.form.value = rues;
                    var ruest = [];
                    ruest.push(row.major_kind_id);
                    ruest.push(row.major_id);
                    this.form.values = ruest;
                    this.form.first_kind_id = row.first_kind_id;
                    this.form.second_kind_id = row.second_kind_id;
                    this.form.third_kind_id = row.third_kind_id;
                    this.form.major_kind_id = row.major_kind_id;
                    this.form.major_id = row.major_id;
                    this.form.first_kind_name = row.first_kind_name;
                    this.form.second_kind_name = row.second_kind_name;
                    this.form.third_kind_name = row.third_kind_name;
                    this.form.major_kind_name = row.major_kind_name;
                    this.form.major_name = row.major_name;
                    this.form.engage_type = row.engage_type;
                    this.form.human_amount = row.human_amount;
                    this.form.deadline = row.deadline;
                    this.form.major_describe = row.major_describe;
                    this.form.engage_required = row.engage_required;
                    this.form.mre_id = row.mre_id;
                    this.dialogVisibleUpdate = true;
                },
                fill() {
                    //用户表查询
                    axios.get('/users/que', {
                    })
                        .then(res => {
                            console.info(res);
                            this.listm = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //职位发布表分页查询
                    axios.get('/engage_major_releaseTo/Quer', {
                        params: {
                            currentPage: this.queryinfo.currentPage,
                            pageSize: this.queryinfo.pageSize
                        }
                    })
                        .then(res => {
                            console.info(res);
                            this.list = res.data.Data;
                            this.total = res.data.Row;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //机构表查询
                    axios.get('/engage_major_release/Dg', {
                    })
                        .then(res => {
                            console.info(res);
                            this.lis = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //职位表查询
                    axios.get('/engage_major_release/Dgto', {
                    })
                        .then(res => {
                            console.info(res);
                            this.lisd = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                },
                //分页显示数改变事件
                handleSizeChange(val) {
                    this.queryinfo.pageSize = val;
                    this.fill();
                },
                //分页当前页改变事件
                handleCurrentChange(val) {
                    this.queryinfo.currentPage = val;
                    this.fill();
                },
                adminSelect(value, thsAreaCode) {
                    //获取组件名为cascaderAddr的选中的节点的labe数据,pathlabes获取labe数组
                    var thsAreaCode = this.$refs.cascaderAddr.getCheckedNodes()[0].pathLabels;
                    var forminsert = value;
                    this.form.first_kind_id = forminsert[0];
                    this.form.second_kind_id = forminsert[1];
                    this.form.third_kind_id = forminsert[2];
                    this.form.first_kind_name = thsAreaCode[0];
                    this.form.second_kind_name = thsAreaCode[1];
                    this.form.third_kind_name = thsAreaCode[2];
                },
                adminSelect1(value, thsAreaCode) {
                    var thsAreaCode = this.$refs.cascaderAddr1.getCheckedNodes()[0].pathLabels;
                    var forminsert = value;
                    this.form.major_kind_id = forminsert[0];
                    this.form.major_id = forminsert[1];
                    this.form.major_kind_name = thsAreaCode[0];
                    this.form.major_name = thsAreaCode[1];
                },
                //当前时间
                get() {
                    this.form.change_time = new Date();
                },
            },
            mounted() {
                //时间计时器
                setInterval(this.get, 1000);
            },
            //可操作vue的数据和方法,但不能对dom进行操作
            created: function () {
                this.fill();
            }
        });
    </script>
    <style scoped>
        ._klpo {
            margin-left: 772px;
        }
        .el-card__body {
            padding: 35px;
        }
        .el-col-2 {
            width: 8.33333%;
            font-size: 15px;
            font-weight: 900;
            line-height: 0px;
        }

        .el-col-4 {
            font-size: 1px;
            font-weight: 300;
            color: rgb(83, 83, 83);
            line-height: 0px;
        }

        element.style {
            height: 100%;
            width: 1239px;
        }

        .el-button.is-circle {
            border-radius: 50%;
            padding: 12px;
            position: relative;
            top: -10px;
            right: -570px;
        }
    </style>
</body>
</html>
